package com.java.demo.Service;

import com.java.demo.dao.UserRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {


    // 1.属性注入  从spring当中取出bean对象,赋值给属性 --- 属性注入  依赖注入
    @Autowired
    private UserRepository userRepository;


    public int add() {
        // 传统写法
        // UserRepository userRepository = new UserRepository();
        // return userRepository.add();
        System.out.println("userservice add ");
        return userRepository.add();
    }
}
